package com.xizi.SynchronizedTest;


public class SynchronizedDemo {
    public void method1() {
        //同步代码块
        synchronized (this) {
            System.out.println("synchronized 代码块");
        }
    }

    //同步方法
    public synchronized void method2() {
        System.out.println("synchronized 方法");
    }

    public static void main(String[] args) {
        SynchronizedDemo a = new SynchronizedDemo();

    }
}